home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / surfmodl / surfm203.arc / SURFSRC.ARC / LITEMENU.INC < prev    next >
Text File  |  1987-12-21  |  5KB  |  118 lines

  1. procedure LITEMENU;
  2. { Menu to change lighting parameters }
  3.  
  4. var Cmmd: integer;         { user's inputted choice }
  5.     Lite: integer;         { light source # }
  6.     Mat: integer;          { material # }
  7.     Eps: real;             { temp for Epsilon }
  8.     Rsh: real;             { temp for Randshade }
  9.  
  10. begin
  11.   repeat
  12.     openwin (13,6,67,21);
  13.     gotoXY (20,1);
  14.     writeln ('LIGHTING MENU');
  15.     writeln; writeln;
  16.     writeln ('1  Material Parameters (', Nmatl,')');
  17.     writeln ('2  Light Sources (', Nlite,')');
  18.     write   ('3  Gouraud Interpolation (');
  19.     if (Interpolate) then
  20.       writeln ('On)')
  21.     else
  22.       writeln ('Off)');
  23.     write   ('4  Shadowing (');
  24.     if (Shadowing) then
  25.       writeln ('On)')
  26.     else
  27.       writeln ('Off)');
  28.     writeln ('0  Return to Parameters Menu');
  29.     writeln;
  30.     write ('Command: ');
  31.     Cmmd := getkey;
  32.     if ((Cmmd < 1) or (Cmmd > 4)) and (Cmmd <> 0) then
  33.       write(^G)
  34.     else begin
  35.       writeln (Cmmd);
  36.       case Cmmd of
  37.         1: begin
  38.           Mat := 1;
  39.           Mat := getoneint (Mat, 1, Nmatl, 'Material Number');
  40.           writeln ('Shading is computing from a formula like:');
  41.           writeln ('  E = I[R1(cos s)**R2 + R3cos n] + Ambient');
  42.           R1[Mat] := getonereal (R1[Mat], 0.0, 99999.0, 'R1');
  43.           R2[Mat] := getonereal (R2[Mat], -99999.0, 99999.0, 'R2');
  44.           R3[Mat] := getonereal (R3[Mat], 0.0, 99999.0, 'R3');
  45.           Color[Mat] := getoneint (Color[Mat], 1, Ncolors, 'Color');
  46.           Ambient[Mat] := getonereal (Ambient[Mat], 0.0, 1.0, 'Ambient Light');
  47.         end; { 1: }
  48.         2: begin
  49.           if (Nlite > 1) then
  50.             writeln ('There are currently ', Nlite, ' light sources.')
  51.           else
  52.             writeln ('There is currently ', Nlite, ' light source.');
  53.           writeln ('Entering a light source number of 0 deletes the last');
  54.           writeln ('  light source.  Entering a light source number of ',
  55.                   Nlite+1);
  56.           writeln ('  will add a new light source.');
  57.           Lite := 1;
  58.           Lite := getoneint (Lite, 0, Nlite+1, 'Light Source Number');
  59.           if (Lite = 0) then begin
  60.             if (Nlite < 2) then begin
  61.               writeln ('Error: Cant delete all light sources!');
  62.               write ('Press any key...');
  63.               while (not keypressed) do;
  64.             end else
  65.               Nlite := Nlite - 1;
  66.           end;
  67.           if (Lite > Nlite) then begin
  68.             Nlite := Nlite + 1;
  69.             Lite := Nlite;
  70.           end;
  71.           if (Lite > 0) then begin
  72.             Xlite[Lite] := getonereal (Xlite[Lite], -99999.0, 99999.0, 'X');
  73.             Ylite[Lite] := getonereal (Ylite[Lite], -99999.0, 99999.0, 'Y');
  74.             Zlite[Lite] := getonereal (Zlite[Lite], -99999.0, 99999.0, 'Z');
  75.             Intensity[Lite] := getonereal (Intensity[Lite], 0.0, 2.0,
  76.                                'Intensity');
  77.           end; { if Lite }
  78.         end; { 2: }
  79.         3: begin
  80.           writeln ('Epsilon: Largest Change in Shading to Interpolate');
  81.           writeln ('  A value of about 0.3 usually works well.');
  82.           writeln ('  Enter a value of 0.0 for no interpolation.');
  83.           Eps := Epsilon;
  84.           Eps := getonereal (Eps, 0.0, 1.0, 'Epsilon');
  85.           if (Eps > 0.0) then begin
  86.             Interpolate := TRUE;
  87.             Epsilon := Eps;
  88.           end else
  89.             Interpolate := FALSE;
  90.           if (Interpolate) then begin
  91.             writeln ('Entering a random shading value greater than 0');
  92.             writeln ('  will cause the shading at all pixels in a Gouraud');
  93.             writeln ('  interpolated rendering to be increased by a random');
  94.             writeln ('  value in the range of 0 to the Random Shade.');
  95.             writeln ('(Recommended values are no greater than the size of');
  96.             writeln ('  one distinguishable shade -- for instance, on a 16');
  97.             writeln ('  shade system, use numbers no greater than ',
  98.                      (1.0/16.0):7:3,')');
  99.             Rsh := Randshade;
  100.             Rsh := getonereal (Rsh, 0.0, 1.0, 'Random Shade');
  101.             if (Rsh > 0.0) then begin
  102.               Dorandom := TRUE;
  103.               Randshade := Rsh;
  104.             end else
  105.               Dorandom := FALSE;
  106.           end; { if Interpolate }
  107.         end; { 3: }
  108.         4: begin
  109.           if (Shadowing) then
  110.             Shadowing := FALSE
  111.           else
  112.             Shadowing := TRUE;
  113.         end; { 4: }
  114.       end; { case Cmmd }
  115.     end;
  116.   until (Cmmd = 0)
  117. end; { procedure Litemenu }
  118.